<?php

namespace App\Models\User;

// use Illuminate\Contracts\Auth\MustVerifyEmail;
use App\Models\Common\Media;
use App\Models\Wechat\WechatMiniUser;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;

class User extends Authenticatable
{
    use HasApiTokens, HasFactory, Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array<int, string>
     */
    protected $guarded = [];

    /**
     * The attributes that should be cast.
     *
     * @var array<string, string>
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
        'password' => 'hashed',
    ];

    public function wechatMiniUser() : HasMany
    {
        return $this->hasMany(WechatMiniUser::class, 'user_id');
    }

    public function avatarFile() : BelongsTo
    {
        return $this->belongsTo(Media::class, 'avatar');
    }

    public function familyUsers() : HasMany
    {
        return $this->hasMany(FamilyUser::class, 'user_id');
    }
}
